package com.etlmaster.rest.server_rowProcess;

import java.util.HashMap;
import java.util.Map;

import javax.ws.rs.GET;
import javax.ws.rs.Path;
import javax.ws.rs.Produces;
import javax.ws.rs.QueryParam;
import javax.ws.rs.core.MediaType;

import com.etlmaster.executor.trans.core.Line;
import com.etlmaster.executor.trans.core.LineMeta;
import com.etlmaster.executor.utils.JsonHelper;
import com.etlmaster.executor.utils.LogWriter;
import com.etlmaster.rowprocessor.core.JobManager;

/**
 * @author Larry
 * @copyright Larry@etlMaster
 * @since 2017-09-10
 */
@Path("etlmaster_rowProcess")
public class ServerRests_RowProcess {
	private volatile static Map<String, String> maxRowKey = new HashMap<String, String>();
	private LineMeta meta=new LineMeta();
	@GET
	@Path("logEvent")
	@Produces(MediaType.TEXT_PLAIN)
	public  String logEvent(@QueryParam("jobName") String jobName,
			@QueryParam("event") String event) {
		LogWriter.addLog("INFO", "收到rest 请求 logEvent,{}", event);
		Map<String, Object> table = (Map<String, Object>) JsonHelper
				.getInstance().read(event);
		Line line=Line.fromJson("", event,meta);
		JobManager.getJobs().get(jobName).getReader().sendData(line);
		return "success";
	}
	public static Map<String, String> getMaxRowKey() {
		return maxRowKey;
	}

	public static void setMaxRowKey(Map<String, String> maxRowKey) {
		ServerRests_RowProcess.maxRowKey = maxRowKey;
	}
	
}
